<include file="public@header" />
</head>
<body>
	<div class="wrap">
		<ul class="nav nav-tabs">
			<li><a href="{:url('sign_up/index')}">报名课程列表</a></li>
        	<li class="active"><a>编辑报名课程</a></li>
		</ul>
		<form method="post" class="form-horizontal js-ajax-form margin-top-20" action="{:url('sign_up/edit')}">
			<div class="form-group">
				<label class="col-sm-2 control-label">
					<span class="form-required">*</span>报名课程名称
				</label>
				<div class="col-md-6 col-sm-10">
					<input type="text" class="form-control" name="title" value="{$row.title}">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">
					<span class="form-required">*</span>所属课程
				</label>
				<div class="col-md-6 col-sm-10">
					<select class="form-control" name="course_id">
						<option value="">---请选择---</option>
						<foreach name="course_list" item="vo">
							<option value="{$vo.id}" <if $vo.id == $row.course_id>selected</if> >{$vo.title}</option>
						</foreach>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">
					<span class="form-required">*</span>届次
				</label>
				<div class="col-md-2 col-sm-10">
					<input type="text" class="form-control" name="session" value="{$row.session}">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">
					<span class="form-required">*</span>报名时间
				</label>
				<div class="checkbox-inline">
					<label class="">
						<input type="text" class="form-control js-bootstrap-datetime" name="sign_up_start_time" autocomplete="off" value="{$row.sign_up_start_time}">
					</label>
					~
					<label class="">
						<input type="text" class="form-control js-bootstrap-datetime" name="sign_up_end_time" autocomplete="off" value="{$row.sign_up_end_time}">
					</label>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">
					<span class="form-required">*</span>老学员优先报名
				</label>
				<div class="col-md-6 col-sm-10">
	                <label class="radio-inline">
	                    <input type="radio" name="first" value="0" <if 0 == $row.first>checked</if> >否
	                </label>
	                <label class="radio-inline">
	                    <input type="radio" name="first" value="1" <if 1 == $row.first>checked</if> >是
	                </label>
	            </div>
			</div>
			<div class="form-group" style="<if !$row.first>display:none;</if>" id="first_start_time">
				<label class="col-sm-2 control-label">
					<span class="form-required">*</span>优先报名开始时间
				</label>
				<div class="checkbox-inline">
					<label class="">
						<input type="text" class="form-control js-bootstrap-datetime" name="first_start_time" autocomplete="off" value="{$row.first_start_time}">
					</label>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">
					<span class="form-required">*</span>培训日期
				</label>
				<div class="checkbox-inline">
					<label class="">
						<input type="text" class="form-control js-bootstrap-datetime" name="train_start_time" autocomplete="off" value="{$row.train_start_time}">
					</label>
					~
					<label class="">
						<input type="text" class="form-control js-bootstrap-datetime" name="train_end_time" autocomplete="off" value="{$row.train_end_time}">
					</label>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">
					<span class="form-required">*</span>上课时间
				</label>
				<div class="col-md-2 col-sm-6">
					<input type="text" class="form-control" name="class_time" value="{$row.class_time}">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">
					<span class="form-required">*</span>培训地址
				</label>
				<div class="col-md-6 col-sm-10">
					<input type="text" class="form-control" name="address" value="{$row.address}">
					<a onclick="doSelectLocation(this)">选择地址</a>
					<input type="hidden" name="lat" value="{$row.lat}">
					<input type="hidden" name="lng" value="{$row.lng}">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">
					<span class="form-required">*</span>培训老师
				</label>
				<div class="col-md-2 col-sm-6">
					<input type="text" class="form-control" name="teacher" value="{$row.teacher}">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">
					<span class="form-required">*</span>报名开课人数和上限
				</label>
				<div class="checkbox-inline">
					<label class="">
						<input type="number" class="form-control" name="min_num" autocomplete="off" value="{$row.min_num}">
					</label>
					~
					<label class="">
						<input type="number" class="form-control" name="max_num" autocomplete="off" value="{$row.max_num}">
					</label>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">
					<span class="form-required">*</span>性别限制
				</label>
				<div class="col-md-6 col-sm-10">
	                <label class="radio-inline">
	                    <input type="radio" name="sex" value="0" <if 0 == $row.sex>checked</if> >不限
	                </label>
	                <label class="radio-inline">
	                    <input type="radio" name="sex" value="1" <if 1 == $row.sex>checked</if> >仅限男士
	                </label>
	                <label class="radio-inline">
	                    <input type="radio" name="sex" value="2" <if 2 == $row.sex>checked</if> >仅限女士
	                </label>
	            </div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">
					<span class="form-required">*</span>年龄范围
				</label>
				<div class="checkbox-inline">
					<label class="">
						<select class="form-control" name="min_age">
							<option value="">---请选择---</option>
							<?php for ($i=50; $i < 90; $i++) { ?>
								<option value="{$i}" <if $i == $row.min_age>selected</if> >{$i}</option>
							<?php }?>
						</select>
					</label>
					~
					<label class="">
						<select class="form-control" name="max_age">
							<option value="">---请选择---</option>
							<?php for ($i=50; $i <= 90; $i++) { ?>
								<option value="{$i}" <if $i == $row.max_age>selected</if> >{$i}</option>
							<?php }?>
						</select>
					</label>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">
					<span class="form-required">*</span>报名费用
				</label>
				<div class="col-md-2 col-sm-6">
					<input type="text" class="form-control" name="cost" value="{$row.cost}">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">
					<span class="form-required">*</span>学员合格签到次数
				</label>
				<div class="col-md-2 col-sm-6">
					<input type="text" class="form-control" name="qualified_num" value="{$row.qualified_num}">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">
					<span class="form-required">*</span>首页展示
				</label>
				<div class="col-md-6 col-sm-10">
	                <label class="radio-inline">
	                    <input type="radio" name="index" value="0" <if 0 == $row.index>checked</if> >否
	                </label>
	                <label class="radio-inline">
	                    <input type="radio" name="index" value="1" <if 1 == $row.index>checked</if> >是
	                </label>
	            </div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">
					<span class="form-required"></span>班长
				</label>
				<div class="col-md-2 col-sm-6" id="monitor">
					<!-- <select class="form-control" name="monitor">
						<option value="0">无</option>
						<foreach name="user_list" item="vo">
							<option value="{$vo.id}" <if $vo.id == $row.monitor>selected</if> >{$vo.name}</option>
						</foreach>
					</select> -->
				</div>
			</div>
			<div class="form-group">
				<div class="col-sm-offset-2 col-sm-10">
					<input type="hidden" name="id" value="{$row.id}">
					<button type="submit" class="btn btn-primary js-ajax-submit">{:lang('SAVE')}</button>
				</div>
			</div>
		</form>
	</div>
	<script src="__STATIC__/js/admin.js"></script>
	<script src="__STATIC__/layui/layui.js"></script>
	<script type="text/javascript">
	//加载组件
		layui.config({
			base: '__STATIC__/layui/dist/'
		}).extend({
			xmSelect: 'xm-select'
		}).use(['xmSelect'], function(){
			var xmSelect = layui.xmSelect;
			
			var json_user_list = eval('{$json_user_list}');
			var data = new Array();
			var monitor ='{$row.monitor}';
			if(monitor){
				data[0] = {name:'无',value:0};
			}else{
				data[0] = {name:'无',value:0,selected:true};
			}
			var k = 0;
			for (var key in json_user_list) {
				k++;
				if(json_user_list[key]['id'] == monitor){
					var arr = {name:json_user_list[key]['name']+'-'+json_user_list[key]['mobile'],value:json_user_list[key]['id'],selected:true};
				}else{
					var arr = {name:json_user_list[key]['name']+'-'+json_user_list[key]['mobile'],value:json_user_list[key]['id']};
				}
				data[k] = arr;
			}

			//渲染多选
			var monitor = xmSelect.render({
			    el: '#monitor',
			    name: 'monitor',
			    radio: true,
			    theme: {color: '#f37b1d'},
			    filterable: true,
			    data: data
			});
			
	});

	function doSelectLocation(obj) {
        var $obj       = $(obj);
        var title      = $obj.data('title');
        var $realInput = $obj;
        var location   = $realInput.val();

        openIframeLayer(
            "{:url('sign_up/map')}?location=" + location,
            '选择定位',
            {
                area: ['700px', '90%'],
            }
        );
    }

    $('input[name=first]').click(function(){
    	var val = $(this).val();
    	if(val == 1){
    		$('#first_start_time').show();
    	}else{
    		$('#first_start_time').hide();
    		$('input[name=first_start_time]').val('');
    	}
    })
	</script>
</body>
</html>